package com.timepies.button;

import android.app.ListActivity;
import android.os.Bundle;

import com.timepies.domain.TimepieAdapterDatabase;
import com.timepies.persistence.DbManager;

public class MyListView extends ListActivity {

	private DbManager db;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		db = new DbManager(this);
		setListAdapter(new TimepieAdapterDatabase(this, db.query(), 0));
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	// public static ListView addTo(final MainlistActivity activity) {
	// Cursor cursor = activity.getDb().query();
	// ListView list = (ListView) activity.findViewById(R.id.pie_main_list);
	// list.setAdapter(new TimepieAdapterDatabase(activity, cursor, 0));
	// list.setOnItemClickListener(getListener(activity));
	//
	// TextView istruzioni = (TextView) activity.findViewById(R.id.istruzioni);
	// if (list == null || list.getCount() == 0)
	// istruzioni.setVisibility(View.VISIBLE);
	// else
	// istruzioni.setVisibility(View.GONE);
	//
	// return list;
	// }
	//
	// private static OnItemClickListener getListener(
	// final MainlistActivity activity) {
	//
	// return new OnItemClickListener() {
	// public void onItemClick(AdapterView<?> parent, View v,
	// int position, long id) {
	// Log.d(this.getClass().getSimpleName(), "position:" + position
	// + " id:" + id);
	//
	// String data = ((TextView) v.findViewById(R.id.txt_date))
	// .getText().toString();
	//
	// String testo = ((TextView) v.findViewById(R.id.txt_testo))
	// .getText().toString();
	//
	// String oggetto = ((TextView) v.findViewById(R.id.txt_oggetto))
	// .getText().toString();
	//
	// Intent i = new Intent(activity, PieActivity.class);
	// i.putExtra("pieObj", new Timepie(id, data, oggetto, testo));
	// activity.startActivity(i);
	// activity.finish();
	// Log.d(this.getClass().getSimpleName(), "position:" + position
	// + " id:" + id + " SENDED!");
	//
	// }
	// };
	// }
}
